package com.logistics.web.struts2.interceptors;

import cn.easybuild.core.exceptions.ApplicationException;

import com.logistics.admin.BaseAction;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


public class CheckLoginInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		if (invocation.getAction() instanceof BaseAction) {
			BaseAction action = (BaseAction) invocation.getAction();
			if (action.isRequireLogon() && !action.isLogon()) {
				return action.getLoginResultName();
			}
		}else {
        	throw new ApplicationException("The action must extend AdminBaseAction.");
        }
		
		return invocation.invoke();
	}
}
